using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace Utilities
{
  public static class Geometry
  {
      public static float pi = MathHelper.Pi;

    public static float sin(float x) {return (float)Math.Sin(x);}
    public static float cos(float x) {return (float)Math.Cos(x);}

    public static IEnumerable<VertexPositionTexture> sphere_vertices(int w, int h)
    {
      return  from i in Enumerable.Range(0, w)
              let a = i / (w-1.0f)
              from j in Enumerable.Range(0, h)
              let b = j / (h-1.0f)
              let v = new Vector3(sin(b * pi) * cos (a * pi * 2.0f), cos(b * pi), sin(b * pi) *sin (a * pi * 2.0f))
              let uv = new Vector2(a,b)
              select new VertexPositionTexture(v, uv);

    }

    //let sphere_indices w h =
    //  seq{for i in 0..w-2 do
    //        for j in 0..h-2 do
    //          let A = (i+0) + (j+0) * w |> uint16
    //          let B = (i+1) + (j+0) * w |> uint16
    //          let C = (i+0) + (j+1) * w |> uint16
    //          let D = (i+1) + (j+1) * w |> uint16
    //          yield! [A;B;C;B;D;C]
  }
}
